﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DeleteFile.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the DeleteFile type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Tests.Support.Actions
{
    using System;
    using System.IO;

    using Macros;

    using Engine;

    public class DeleteFile : ActionBase<FileProperties>
    {
        #region IAction Members

        #endregion

        protected override ProcessStatus DoAction(SafContext context, FileProperties props)
        {
            this.Trace.TraceMethodStart("DoAction");

            string fullPath = props.FilePath;
            if (File.Exists(fullPath))
            {
                File.Delete(fullPath);
            }

            this.Trace.TraceMethodEnd("DoAction");
            
            // Successful Result, lets continue processing the 
            // next Actions (if any).
            return ProcessStatus.Success;
        }

        protected override ProcessStatus UndoAction(SafContext context, FileProperties props)
        {
            return ProcessStatus.Success;
        }

        #region IPostProcessor Members

        public ProcessStatus PostProcess(SafContext context, Exception exception)
        {
            return ProcessStatus.Success;
        }

        #endregion
    }
}